// .txt

beginzonescript;

variables;

short im_hostile = 0;
short last_abil;
short counter = 0;
short set_ter1 = 0;
short r1 = 0;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

	set_name(30001,"Stoff Warrior");
	set_name(4400,"Dhregn Stoff");
	set_walk_speed(4401,0);
	set_walk_speed(4402,0);
		set_attack_range(30001,4);



	set_attack_range(30002,3);
	set_attack_range(30003,3);

	set_name(30004,"Leaping Goocorpse");
	add_ability(30004,10,49,0);

	if (gf(44,11) == 0) {
		sf(44,13,0);
		sf(44,14,0);
		sf(44,17,0);
		}
		else {
			kill_object(15,1);
			kill_object(31,1);
			}
			
//	add_ability(short which_char_or_group,short which_slot,short which_ability,0);

//	if (is_town_clear(ME))
//		clean_up_town();

	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	//if ((set_ter1 == 0) && (gf(0,0) > 0)) {
	//	set_ter1 = 1;
	//	set_terrain(,,,);
	//	}
		
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4400,"We welcome you.");
	if (gf(44,11) == 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4400,"Has help come?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4400,"The spirits never end.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4400,"The dead walk.");
		}
	if (gf(44,11) > 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4400,"The mine is ours!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4400,"We'll charge admission!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4400,"Our clan is saved.");
		}

	if ((on_which_layer() == 1) && (party_within_dist(31,30,4)) && (gf(44,13) == 0)) {
		sf(44,13,1);
		
		spawn_creature(4432);
		spawn_creature(4434);
		spawn_creature(4436);
		spawn_creature(4438);
		
		begin_talk_mode(14);
		}
	
	if (gf(44,11) == 1) {
		sf(44,11,2);
		clear_town(44);
		begin_talk_mode(16);
		}
			
	//if (gf(,) < 2) {
	//	inc_flag(,,1);
	//	if (gf(,) == 2)
	//		begin_talk_mode();
	//	}

	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_town()) && (tick_difference(last_abil,get_current_tick()) > 5))) {
		last_abil = get_current_tick();
		
		if ((on_which_layer() == 0) && (gf(44,11) == 0) && (party_within_dist(33,45,7)) && (char_ok(4408) == FALSE) && (char_ok(4409) == FALSE) && (get_ran(1,0,15) == 1)) {
		spawn_creature(4408);
		spawn_creature(4409);
		set_name(4408,"Wispy Shade");
		set_summon_level(4408,2);
		set_name(4409,"Wispy Shade");
		set_summon_level(4409,2);
			set_terrain_string("More shades float toward the camp!");
			}
		
		if ((gf(44,13) > 0) && (gf(44,13) < 100)) {
			if (gf(44,17) >= 20 + 5 * difficulty()) {
				spawn_creature(4440);
				if (char_ok(4440)) {
					sf(44,13,100);
					set_name(4440,"Dragon Wisp");
					set_summon_level(4440,2);
					
					begin_talk_mode(15);
					end();
					}
				}
			
			r1 = get_ran(1,0,7);
			if (char_ok(4432 + r1) == FALSE) {
				spawn_creature(4432 + r1);
				}
			r1 = get_ran(1,0,7);
			if (char_ok(4432 + r1) == FALSE) {
				spawn_creature(4432 + r1);
				}
			r1 = get_ran(1,0,7);
			if (char_ok(4432 + r1) == FALSE) {
				spawn_creature(4432 + r1);
				}
			r1 = get_ran(1,0,7);
			if ((char_ok(4432 + r1) == FALSE) && (difficulty() > 1)) {
				spawn_creature(4432 + r1);
				}
			}
		
		}
break;

beginstate 10;
	if ((gf(44,13) > 0) && (gf(44,14) == 0)) {
		activate_hidden_group(8);
		sf(44,14,1);
		
		set_name(4441,"Druid of the Lost");
		set_boss_level(4441,1);
		
		if (difficulty() < 2)
			erase_char(4447);
		
		talk_no_exit(40);
		}
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

//	print_str("");
//	set_terrain_string_range(".",1);
//	set_terrain_string_range("The sign says - .",1);
